import React, { Component } from 'react';
import { StoreProvider, Relax } from 'iflux2';
import AppStore from './store.js';
import './index.less'
import Tab from './component/tab'
import Content from './component/content'

@Relax
@StoreProvider(AppStore)
export default class AppContainer extends Component {

    static defaultProps = {
        status: ''
    }

    componentDidMount() {
        const { page } = this.props.params;
        this.props.store._initNewsList(1, page);
        this._toggle(true);
    }

    componentWillUnmount() {
        this._toggle(false);
    }

    render() {
        return (
            <div className="newsArea">
                <Tab />
                <Content />
            </div>
        )
    }

    _toggle(show = false) {
        document.querySelector('.SideNav a[href="#/news"]').classList[show ? 'add' : 'remove']('active');
    }
}